﻿using System;
using Syncfusion.Pdf.Parsing;

namespace PdfSdk.Pdf
{
    public class PdfNumberWrapper : ObjectWrapper, IPdfPrimitiveWrapper
    {
        private static Type s_type;

        public static PdfNumberWrapper Create(float value)
        {
            s_type ??= Type.GetType($"Syncfusion.Pdf.Primitives.PdfNumber, {typeof(PdfLoadedDocument).Assembly.FullName}");
            var obj = CreateInstance(s_type, value);
            return new PdfNumberWrapper(obj);
        }

        public PdfNumberWrapper(object obj) : base(obj)
        {
        }

        public int IntValue
        {
            get => Convert.ToInt32(GetPropertyValue());
            set => SetPropertyValue(value);
        }

        public float FloatValue
        {
            get => Convert.ToSingle(GetPropertyValue());
            set => SetPropertyValue(value);
        }
    }
}
